const { defineConfig } = require('@vue/cli-service')
const TerserPlugin=require("terser-webpack-plugin")
module.exports = defineConfig({
  transpileDependencies: true,
  devServer:{
    open:true,
    port:8080,
    allowedHosts:"all"
  },
  //当npm build的时候  关闭源码映射
  productionSourceMap:false,

  configureWebpack:(config)=>{
    // 只有npm run build的时候才是production
    if (process.env.NODE_ENV === "production") {
      return {
        plugins: [
          //打包环境去掉console.log
          new TerserPlugin({
            // 多进程：加速打包速度
            parallel: true,
            terserOptions: {
              ecma: undefined,
              warnings: false,
              parse: {},
              compress: {
                drop_console: true,
                drop_debugger: false,
                pure_funcs: ["console.log"], // 移除console
              },
            },
          }),
        ],
      };
    }
  }
})

